package com.xored.glance.internal.ui.panels;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.preference.IPreferenceStore;

import com.xored.glance.internal.ui.GlancePlugin;

/**
 * @author Yuri Strot
 */
public class CheckAction extends Action {

	public CheckAction(String name, String label) {
		super(label, AS_CHECK_BOX);
		this.name = name;
		setChecked(getStore().getBoolean(name));
	}

	public IPreferenceStore getStore() {
		return GlancePlugin.getDefault().getPreferenceStore();
	}

	@Override
	public void run() {
		getStore().setValue(name, isChecked());
	}

	private String name;
}
